home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / you-075a.lha / you-075a / slots.c < prev    next >
C/C++ Source or Header  |  1992-06-18  |  4KB  |  120 lines

  1. /* ******************************************************************** */
  2. /*  slots.c          Copyright (C) Codemist and University of Bath 1989 */
  3. /*                                                                      */
  4. /* Slot stuff                                                    */
  5. /* ******************************************************************** */
  6.  
  7. /*
  8.  * Change Log:
  9.  *   Version 1, Noveber 1989
  10.  *   Abstracted the slot access operations from the class ops into this file
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include "funcalls.h"
  15. #include "defs.h"
  16. #include "structs.h"
  17. #include "global.h"
  18. #include "error.h"
  19.  
  20. #include "bootstrap.h"
  21. #include "table.h" 
  22. #include "ngenerics.h"
  23.  
  24. #include "class.h"
  25.  
  26. #include "modboot.h"
  27. #include "slots.h"
  28.  
  29. /* The slot form access primitives */
  30.  
  31. EUFUN_1( Fn_slot_description_name, desc)
  32. {
  33.   if (EUCALL_2(Fn_subclassp,classof(desc),Slot_Description) == nil)
  34.     CallError(stacktop,"slot-description-name: not slot description",
  35.           ARG_1(stackbase),NONCONTINUABLE);
  36.  
  37.   return(slot_desc_name(ARG_0(stackbase)));
  38. }
  39. EUFUN_CLOSE
  40.  
  41. EUFUN_1( Fn_slot_description_position, desc)
  42. {
  43.   if (EUCALL_2(Fn_subclassp,classof(desc),Slot_Description) == nil)
  44.     CallError(stacktop,"slot-description-position: not slot description",
  45.           ARG_0(stackbase),NONCONTINUABLE);
  46.  
  47.   return(slot_desc_position(ARG_0(stackbase)));
  48. }
  49. EUFUN_CLOSE
  50.  
  51. EUFUN_2( Fn_slot_description_position_setter, desc, val)
  52. {
  53.   if (EUCALL_2(Fn_subclassp,classof(desc),Slot_Description) == nil)
  54.     CallError(stacktop,
  55.           "(setter slot-description-position): not slot description",
  56.           ARG_0(stackbase),NONCONTINUABLE);
  57.  
  58.   return(slot_desc_position(ARG_0(stackbase)) = ARG_1(stackbase));
  59. }
  60. EUFUN_CLOSE
  61.  
  62. EUFUN_1( Fn_slot_description_initargs, desc)
  63. {
  64.   if (EUCALL_2(Fn_subclassp,classof(desc),Slot_Description) == nil)
  65.     CallError(stacktop,"slot-description-initargs: not slot description",
  66.           ARG_0(stackbase),NONCONTINUABLE);
  67.  
  68.   return(slot_desc_initargs(ARG_0(stackbase)));
  69. }
  70. EUFUN_CLOSE
  71.  
  72. EUFUN_1( Fn_slot_description_initform, desc)
  73. {
  74.   if (EUCALL_2(Fn_subclassp,classof(desc),Slot_Description) == nil)
  75.     CallError(stacktop,"slot-description-initform: not slot description",
  76.           ARG_0(stackbase),NONCONTINUABLE);
  77.  
  78.   return(slot_desc_initform(ARG_0(stackbase)));
  79. }
  80. EUFUN_CLOSE
  81.  
  82. EUFUN_2( Fn_find_slot_description, class, slot_name)
  83. {
  84.   if (typeof(class) != TYPE_CLASS) 
  85.     CallError(stacktop,
  86.           "non class in find_slot_description",class,NONCONTINUABLE);
  87.   if (!is_symbol(slot_name))
  88.     CallError(stacktop,
  89.           "non symbol for slot name in find_slot_description",slot_name,
  90.           NONCONTINUABLE);
  91.  
  92.   if (class->CLASS.slot_table == nil) 
  93.     return(nil);
  94.   else
  95.     return(EUCALL_2(Fn_tref,class->CLASS.slot_table,slot_name));
  96. }
  97. EUFUN_CLOSE
  98.  
  99. /* Initialise this 'module' */
  100. #define SET_ASSOC(a,b) \
  101.   { LispObject tmp,tmp2; \
  102.     STACK_TMP(a); \
  103.     tmp2=b; \
  104.     UNSTACK_TMP(tmp); \
  105.     set_anon_associate(stacktop,tmp,tmp2); \
  106.   }
  107. void initialise_slots(LispObject *stacktop)
  108. {
  109.   (void) make_module_function(stacktop,"slot-description-name",
  110.                   Fn_slot_description_name,1);
  111.   SET_ASSOC(make_module_function(stacktop,"slot-description-position",
  112.                  Fn_slot_description_position,1),
  113.        make_unexported_module_function(stacktop,"s-d-p-s",
  114.                        Fn_slot_description_position_setter,2));
  115.   (void) make_module_function(stacktop,"slot-description-initargs",
  116.                   Fn_slot_description_initargs,1);
  117.   (void) make_module_function(stacktop,"slot-description-initform",
  118.                   Fn_slot_description_initform,1);
  119. }
  120.